package com.ruoyi.shop.domain;

import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

/**
 * 优惠券对象 shop_coupon
 * 
 * @author Alan Zhang
 * @date 2021-09-18
 */
public class ShopCoupon extends BaseEntity
{
    private static final long serialVersionUID = 1L;
    //优惠码的验证类型：绝对有效，（XXX-XXX时间段有效）
    public static final int VALID_TYPE_ABSOLUTELY_EFFECTIVE = 1;

    //优惠码的验证类型：相对时效（领取后N天有效）
    public static final int VALID_TYPE_RELATIVELY_EFFECTIVE = 2;


    //1正常  2不能使用
    public static final int STATUS_NORMAL = 1;
    public static final int STATUS_INVALID = 2;

    //满减券
    public static final int TYPE_FULL_DISCOUNT = 1;

    //叠加满减券
    public static final int TYPE_SUPERIMPOSED_FULL_DISCOUNT = 2;

    //无门槛券
    public static final int TYPE_NO_THRESHOLD = 3;

    public boolean isNormal() {
        Integer status = getStatus();
        return status != null && status == STATUS_NORMAL;
    }

    /** 优惠券id */
    private Long id;

    /** 优惠券名称 */
    @Excel(name = "优惠券名称")
    private String title;

    /** 图片 */
    @Excel(name = "图片")
    private String icon;

    /** 类型 1满减券  2叠加满减券  3无门槛券 */
    @Excel(name = "类型")
    private Integer type;

    /** 满多少金额 */
    @Excel(name = "满多少金额")
    private BigDecimal withAmount;

    /** 优惠券金额 */
    @Excel(name = "优惠券金额")
    private BigDecimal amount;

    /** 配额：发券数量 */
    @Excel(name = "发券数量")
    private Long quota;

    /** 已领取的优惠券数量 */
    @Excel(name = "已领取的优惠券数量")
    private Long takeCount;

    /** 已使用的优惠券数量 */
    @Excel(name = "已使用的优惠券数量")
    private Long usedCount;

    /** 发放开始时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "发放开始时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date startTime;

    /** 发放结束时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "发放结束时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date endTime;

    /** 时效:1绝对时效（XXX-XXX时间段有效）  2相对时效（领取后N天有效） */
    @Excel(name = "时效")
    private Integer validType;

    /** 使用开始时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "使用开始时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date validStartTime;

    /** 使用结束时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "使用结束时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date validEndTime;

    /** 自领取之日起有效天数 */
    @Excel(name = "自领取之日起有效天数")
    private Integer validDays;

    /** 状态 1 正常  2 不能使用 */
    @Excel(name = "状态")
    private Integer status;

    public void setId(Long id) 
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }
    public void setTitle(String title) 
    {
        this.title = title;
    }

    public String getTitle() 
    {
        return title;
    }
    public void setIcon(String icon) 
    {
        this.icon = icon;
    }

    public String getIcon() 
    {
        return icon;
    }
    public void setType(Integer type) 
    {
        this.type = type;
    }

    public Integer getType() 
    {
        return type;
    }
    public void setWithAmount(BigDecimal withAmount) 
    {
        this.withAmount = withAmount;
    }

    public BigDecimal getWithAmount() 
    {
        return withAmount;
    }
    public void setAmount(BigDecimal amount) 
    {
        this.amount = amount;
    }

    public BigDecimal getAmount() 
    {
        return amount;
    }
    public void setQuota(Long quota) 
    {
        this.quota = quota;
    }

    public Long getQuota() 
    {
        return quota;
    }
    public void setTakeCount(Long takeCount) 
    {
        this.takeCount = takeCount;
    }

    public Long getTakeCount() 
    {
        return takeCount;
    }
    public void setUsedCount(Long usedCount) 
    {
        this.usedCount = usedCount;
    }

    public Long getUsedCount() 
    {
        return usedCount;
    }
    public void setStartTime(Date startTime) 
    {
        this.startTime = startTime;
    }

    public Date getStartTime() 
    {
        return startTime;
    }
    public void setEndTime(Date endTime) 
    {
        this.endTime = endTime;
    }

    public Date getEndTime() 
    {
        return endTime;
    }
    public void setValidType(Integer validType) 
    {
        this.validType = validType;
    }

    public Integer getValidType() 
    {
        return validType;
    }
    public void setValidStartTime(Date validStartTime) 
    {
        this.validStartTime = validStartTime;
    }

    public Date getValidStartTime() 
    {
        return validStartTime;
    }
    public void setValidEndTime(Date validEndTime) 
    {
        this.validEndTime = validEndTime;
    }

    public Date getValidEndTime() 
    {
        return validEndTime;
    }
    public void setValidDays(Integer validDays)
    {
        this.validDays = validDays;
    }

    public Integer getValidDays()
    {
        return validDays;
    }
    public void setStatus(Integer status)
    {
        this.status = status;
    }

    public Integer getStatus() 
    {
        return status;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("title", getTitle())
            .append("icon", getIcon())
            .append("type", getType())
            .append("withAmount", getWithAmount())
            .append("amount", getAmount())
            .append("quota", getQuota())
            .append("takeCount", getTakeCount())
            .append("usedCount", getUsedCount())
            .append("startTime", getStartTime())
            .append("endTime", getEndTime())
            .append("validType", getValidType())
            .append("validStartTime", getValidStartTime())
            .append("validEndTime", getValidEndTime())
            .append("validDays", getValidDays())
            .append("status", getStatus())
            .append("createTime", getCreateTime())
            .append("updateTime", getUpdateTime())
            .toString();
    }
}
